home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_214 / mandelvroom / src / safeaddhead.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  83 lines

  1. /*
  2.  * MandelVroom 2.0
  3.  *
  4.  * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  5.  *
  6.  * All rights reserved.
  7.  *
  8.  * Permission is hereby granted to distribute this program's source
  9.  * executable, and documentation for non-comercial purposes, so long as the
  10.  * copyright notices are not removed from the sources, executable or
  11.  * documentation.  This program may not be distributed for a profit without
  12.  * the express written consent of the author Kevin L. Clague.
  13.  *
  14.  * This program is not in the public domain.
  15.  *
  16.  * Fred Fish is expressly granted permission to distribute this program's
  17.  * source and executable as part of the "Fred Fish freely redistributable
  18.  * Amiga software library."
  19.  *
  20.  * Permission is expressly granted for this program and it's source to be
  21.  * distributed as part of the Amicus Amiga software disks, and the
  22.  * First Amiga User Group's Hot Mix disks.
  23.  *
  24.  * contents: this file contains some routines to check for adding nodes to
  25.  * lists twice, or removing nodes that are not in a list.
  26.  */
  27. #include <exec/lists.h>
  28. #include <exec/nodes.h>
  29.  
  30. #undef AddHead
  31. #undef Remove
  32.  
  33. extern BYTE FromWB;
  34.  
  35. safeAddHead( ListPtr, NodePtr, File, Line, Function )
  36.   register struct List *ListPtr;
  37.   register struct Node *NodePtr;
  38.   char *File, *Function;
  39.   int  Line;
  40. {
  41.   register struct Node *CurNode;
  42.  
  43.   CurNode = ListPtr->lh_Head;
  44.  
  45.   while ( CurNode->ln_Succ ) {
  46.  
  47.     if ( CurNode == NodePtr ) {
  48.       if (! FromWB)
  49.         printf("Error adding node to list twice\n in file %s, line %d, function %s\n",
  50.                 File, Line, Function);
  51.       return;
  52.     }
  53.  
  54.     CurNode = CurNode->ln_Succ;
  55.   }
  56.   AddHead( ListPtr, NodePtr );
  57. }
  58.  
  59. safeRemove( NodePtr, File, Line, Function )
  60.   register struct Node *NodePtr;
  61.   char *File, *Function;
  62.   int  Line;
  63. {
  64.   if (NodePtr->ln_Pred == NULL && !FromWB) {
  65.       printf("Error Removing node when it'd not it list\n");
  66.       printf("In File %s Line %d Function %s\n",File,Line,Function);
  67.   } else {
  68.  
  69.     if (NodePtr->ln_Succ == NULL && !FromWB) {
  70.       printf("Error Removing node when it'd not it list\n");
  71.       printf("In File %s Line %d Function %s\n",File,Line,Function);
  72.     }
  73.   }
  74.  
  75.   Remove( NodePtr );
  76.  
  77.   NodePtr->ln_Pred = NULL;
  78.   NodePtr->ln_Succ = NULL;
  79. }
  80.  
  81.  
  82.  
  83.